const Router = require('koa-router');
const router = new Router();
const tool = require('../../tools/tool')
const {db, QueryTypes} = require("../../models/db");

router.post('/print/printSuc', async ctx => {
    let taskId = ctx.request.body.taskId;
    let t = tool.getTime()
    if (taskId) {
        await db.query(`update print_record set stat=1,printAt='${t}' where taskId='${taskId}'`, {type: QueryTypes.UPDATE});
        await db.query(`update invoice set printNo=isnull(printNo,0)+1 where id in (select iid from print_record where taskId='${taskId}')`, {type: QueryTypes.UPDATE});
    }
    return ctx.suc('');
})

module.exports = router;
